using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ThreeTeams.API.Application.Command.BoxTypeManageMentCommand;
using ThreeTeams.Domain;
using ThreeTeams.ErrorCode;

namespace ThreeTeams.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BoxTypeManagementController : ControllerBase
    {
        private readonly IMediator mediator;

        public BoxTypeManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 获取箱子型号列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<ApiPaging<BoxType>>> GetBoxType([FromQuery] GetBoxTypeCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 添加箱子型号
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreateBoxType(CreateBoxTypeCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除箱子型号
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult<int>> DelBoxType(DeleteBoxTypeCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改箱子型号
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateBoxType(UpdateBoxTypeCommand request)
        {
            return await mediator.Send(request);
        }
    }
} 